package cn.com.huzo.webapp.controller.workflow;

import huzofw.common.web.controller.BaseFormController;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import cn.com.huzo.service.workflow.ApprovalRuleMrpManager;

/**
 * 调达表审核规则控制器
 *
 * @author 吴旭
 */
@Controller
public class ApprovalRuleMrpController extends BaseFormController {

    // <editor-fold defaultstate="collapsed" desc="属性">
    @Resource(name = "ApprovalRuleMrpManager")
    private ApprovalRuleMrpManager _manager;
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="画面处理部分">
    /**
     * 跳转到调达表审核规则一览画面
     * <p>
     * @return
     */
    @RequestMapping("workflow/approval/rule/mrp/list.html")
    public ModelAndView redirectListWnd() {
        ModelAndView view = new ModelAndView();
        view.setViewName("workflow.approval_rule_mrp.list.def");
        return view;
    }
    // </editor-fold>

    // <editor-fold defaultstate="collapsed" desc="调达表审核规则数据处理部分">
    /**
     * 根据标识取得调达表审核规则数据。
     *
     * @param criterion
     * @return 调达表审核数据。
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "workflow/approval/rule/mrp/fetchForPage.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> fetchForPage(@RequestBody Map<String, Object> criterion) throws Exception {
        return _manager.fetchForPage(criterion);
    }

    /**
     * 调达表审核规则增加或者修改
     *
     * @param criterion 要处理的数据
     * @return
     *
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "workflow/approval/rule/mrp/save.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> batchSave(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager.batchUpdate(criterion);
    }

    /**
     * 删除调达表审核规则
     *
     * @param criterion 要删除的数据
     * @return 影响行数
     * @throws java.lang.Exception
     */
    @RequestMapping(value = "workflow/approval/rule/mrp/delete.html",
            method = RequestMethod.POST)
    public @ResponseBody
    Map<String, Object> delete(@RequestBody final Map<String, Object> criterion) throws Exception {
        return _manager.delete(criterion);
    }
    // </editor-fold>
}
